#ifndef __QUEUE__
#define __QUEUE__


#include <vector>
#include <atomic>
#include "IUtility.h"
#include "IContainer.h"
#include "ISysResources.h"


class CQueue : public virtual IQueue
{
INIT_CLASS_PRODUCT(CQueue)
public:
	const bool Init(const void * pvdPara, char * pszMsgTxt, int iMsgTxtSize) override final;
	const void UnInit() override final;
	bool Push(IData * ptrData, int iQueueKey) override final;
	IData * Pop() override final;
	void QueueInfo(long long &llInQueueNum, long long &llOutQueueNum);
	bool EmptyQueue() override final;
	bool FlipQueueKey();
	int QueueKey();
	int QueueType();
private:
	vector<IData *> m_vtQueue;
	shared_ptr<ILock> m_ptrLock, m_ptrLockFlipQueueKey;
	atomic<long long> m_llInQueueNum, m_llOutQueueNum;
	int m_iQueueKey;
    CRITICAL_SECTION m_csLock, m_csLockFlipQueueKey;

private:
	bool CompQueueKey(int iQueueKey);
};




#endif//__QUEUE__